package com.bw.dg.service.impl;

import com.bw.dg.dao.LogDao;
import com.bw.dg.dao.UserDao;
import com.bw.dg.pojo.Log;
import com.bw.dg.pojo.User;
import com.bw.dg.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private LogDao logDao;

    @Override
    public List getUserList(String mohu) {
        return userDao.getUserList();
    }



    @Override
    public void add(User user) {

        userDao.add(user);
        System.out.println(user.getId());
        Log log = new Log();
        log.setCdate(new Date());
        log.setRemark("操作：添加账号管理");
        log.setCz_type("手动添加");
        log.setUid(1);
        logDao.save(log);
    }

    @Override
    public String[] del(String id) {
        return this.userDao.del(id);
    }

    @Override
    public List UsersList(String mohu) {
        return userDao.UsersList(mohu);
    }

    @Override
    public User login(User user) {
        return this.userDao.login(user);
    }


    @Override
    public User huixian(int id) {
        return userDao.huixian(id);
    }

    @Override
    public void update(User user) {
        User user1=userDao.findByName(user.getName());
        user1.setPwd(user.getPwd());
        userDao.update(user1);
    }



}
